package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 调用有参方法
 */
public class ReflectDemo5 {
    public static void main(String[] args) throws IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException {
        Person p = new Person();
        p.say("大家好！");

        Class cls = Class.forName("reflect.Person");
        Object o = cls.newInstance();

        Method m = cls.getMethod("say", String.class,int.class);
        m.invoke(o,"才是真的好~",5 );
    }
}
